﻿using System;
using System.Windows.Forms;

namespace TestStepsEditor
{
    public partial class InsertRowsForm : Form
    {
        public string RowNumber;
        public int TFSID;
        public string Title;
        public string WIType;

        public InsertRowsForm()
        {
            InitializeComponent();
            newWIRadioButton.Checked = true;
        }

        private void OKbutton_Click(object sender, EventArgs e)
        {
            if (oldWIRadioButton.Checked)
            {
                TFSID = Convert.ToInt32(tfsIDTextBox.Text);
                RowNumber = rowNumberTextBox.Text;
            }
            if (newWIRadioButton.Checked)
            {
                if (tcCheckBox.Checked)
                    WIType = "T";
                if (ssCheckBox.Checked)
                    WIType = "S";
                Title = wiTitleTextBox.Text;
            }

            Close();
        }

        private void cancelButton_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void newWIRadioButton_CheckedChanged(object sender, EventArgs e)
        {
            ButtonActions();
        }

        private void ButtonActions()
        {
            if (newWIRadioButton.Checked)
            {
                tfsIDTextBox.Visible = false;
                tfsIDTextBox.Clear();
                rowNumberTextBox.Visible = false;
                rowNumberTextBox.Clear();
                label1.Visible = false;
                label2.Visible = false;
                wiTitleTextBox.Visible = true;
                tcCheckBox.Visible = true;
                ssCheckBox.Visible = true;
                label3.Visible = true;
            }
            if (oldWIRadioButton.Checked)
            {
                tfsIDTextBox.Visible = true;
                rowNumberTextBox.Visible = true;
                wiTitleTextBox.Visible = false;
                wiTitleTextBox.Clear();
                label3.Visible = false;
                tcCheckBox.Visible = false;
                tcCheckBox.Checked = false;
                ssCheckBox.Visible = false;
                ssCheckBox.Checked = false;
                label1.Visible = true;
                label2.Visible = true;
            }
        }

        private void oldWIRadioButton_CheckedChanged(object sender, EventArgs e)
        {
            ButtonActions();
        }

        private void tcCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            if (tcCheckBox.Checked)
                ssCheckBox.Enabled = false;
            else
                ssCheckBox.Enabled = true;
        }

        private void ssCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            if (ssCheckBox.Checked)
                tcCheckBox.Enabled = false;
            else
                tcCheckBox.Enabled = true;
        }
    }
}